package cgl.narada.protocol;

import java.util.ArrayList;
import java.util.Hashtable;

/** This class encapsulates a unit of dispatching work.
    
    @author Shrideep Pallickara
    $Date: 2006/05/05 17:32:15 $
    $Revision: 1.3 $
 */


public class DispatchUnit {
  
  private byte[] payload;

  private ArrayList arrayListDestinations;

  private boolean hasArrayListDestinations = false;

  private Hashtable hashtableDestinations;

  private boolean hasHashtableDestinations = false;
  
  private boolean hasIgnoreDestination = false;
  
  private int ignoreDestination = Integer.MAX_VALUE;
  
  public DispatchUnit(byte[] payload, ArrayList arrayListDestinations, 
		      int ignoreDestination) {
    
    this.payload = payload;
    if (arrayListDestinations != null) {
      this.arrayListDestinations = arrayListDestinations;
      hasArrayListDestinations = true;
    }
    
    this.ignoreDestination = ignoreDestination;
    hasIgnoreDestination = true;
  }


  
  public DispatchUnit(byte[] payload, Hashtable hashtableDestinations, 
		      int ignoreDestination) {
    
    this.payload = payload;
    if (hashtableDestinations != null) {
      this.hashtableDestinations = hashtableDestinations;
      hasHashtableDestinations = true;
    }
    
    this.ignoreDestination = ignoreDestination;
    hasIgnoreDestination = true;
  }


  public byte[] getPayload() {
    return payload;
  }

  public boolean hasHashtableDestinations() {
    return hasHashtableDestinations;
  }

  public Hashtable getHashtableDestinations() {
    return  hashtableDestinations;
  }

  public boolean hasArrayListDestinations() {
    return hasArrayListDestinations;
  }

  public ArrayList getArrayListDestinations() {
    return arrayListDestinations;
  }

  public boolean hasIgnoreDestination() {
    return hasIgnoreDestination;
  }

  public int getIgnoreDestination() {
    return ignoreDestination;
  }

}
